// pages/classHomePage/qiangda/qiangdaMessage/qiangdaMessage.js
const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    qiangda_result: null,
    people:null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let _this = this
    _this.setData({
      people: wx.getStorageSync('people')
    })
    if (options != null) {
      console.log('页面跳转传值：', options)
    }
    let data = {}
    if (wx.getStorageSync("people") == 'student') {
      data = {
        'course_name': app.globalData.banji_info['className'],
        'qiangda_id': options['qiangda_id']
      }
    } else if (wx.getStorageSync("people") == 'teacher') {
      data = {
        'course_name': app.globalData.banji_info['courseName'],
        'qiangda_id': options['qiangda_id']
      }
    }
    app.formPost('/get_qiangda_res?', data).then(res => {
      console.log('获取抢答结果:', res);
      _this.setData({
        qiangda_result: res
      })
    })
  },

  teacher_correct: function () {
    let _this = this
    let data = {
      'is_right': 1,
      'qiangda_id': _this.data.qiangda_result['qiangda_id']
    }
    app.formPost('/qiangda_is_right', data).then(res => {
      console.log('判断结果：', res);
    })
  },

  teacher_error: function () {
    let _this = this
    let data = {
      'is_right': 0,
      'qiangda_id': _this.data.qiangda_result['qiangda_id']
    }
    app.formPost('/qiangda_is_right', data).then(res => {
      console.log('判断结果：', res);
      wx.navigateTo({
        url: '/pages/classHomePage/qiangda/doexam/doexam?qiangda_id=' + String(res[index]['id']),
      })
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})